﻿Imports NMock2

Imports System.Collections.Generic
Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports Meiners.Libs.Withings
Imports Meiners.Libs.Withings.Core

    '''<summary>
    '''This is a test class for MeasureRequestResultTest and is intended
    '''to contain all MeasureRequestResultTest Unit Tests
    '''</summary>
    <TestClass()> _
    Public Class ReadMeasureResponseTest


        Private testContextInstance As TestContext

        '''<summary>
        '''Gets or sets the test context which provides
        '''information about and functionality for the current test run.
        '''</summary>
        Public Property TestContext() As TestContext
            Get
                Return testContextInstance
            End Get
            Set(ByVal value As TestContext)
                testContextInstance = value
            End Set
        End Property


        '''<summary>
        '''A test for UpdateTime
        '''</summary>
        <TestMethod()> _
        Public Sub UpdateTimeTest()
            Dim status As Withings.Core.StatusResponseEnum = Withings.Core.StatusResponseEnum.Successfull
            Dim updateTime As DateTime = DateTime.Now
            Dim hasMore As Boolean = True
        Dim target As GetMeasuresResponse = New GetMeasuresResponse(status, updateTime, hasMore)
        Dim actual As DateTime
        actual = target.UpdateTime
        Assert.AreEqual(Of DateTime)(updateTime, actual)
    End Sub

    '''<summary>
    '''A test for HasMore
    '''</summary>
    <TestMethod()> _
    Public Sub HasMoreTest()
        Dim status As Withings.Core.StatusResponseEnum = Withings.Core.StatusResponseEnum.Successfull
        Dim updateTime As DateTime = DateTime.Now
        Dim hasMore As Boolean = True
        Dim target As GetMeasuresResponse = New GetMeasuresResponse(status, updateTime, hasMore)
        Dim actual As Boolean
        actual = target.HasMore
        Assert.AreEqual(Of Boolean)(hasMore, actual)
    End Sub

    '''<summary>
    '''A test for ReadMeasureGroups
    '''</summary>
    <TestMethod()> _
    Public Sub ReadMeasureGroupsTest()
        Dim status As Withings.Core.StatusResponseEnum = Withings.Core.StatusResponseEnum.Successfull
        Dim updateTime As DateTime = DateTime.Now
        Dim hasMore As Boolean = True
        Dim target As GetMeasuresResponse = New GetMeasuresResponse(status, updateTime, hasMore)
        Dim myMeasureGroup As New MeasureGroup()

        myMeasureGroup.AttributionStatus = AttributionStatusEnum.EnteredManually
        myMeasureGroup.Category = CategoryEnum.IsMeasure
        myMeasureGroup.GroupId = 1234
        myMeasureGroup.MeasureGroupDate = DateTime.Now
        target.AddMeasureGroup(myMeasureGroup)
        Dim actual() As MeasureGroup
        actual = target.ReadMeasureGroups
        Assert.IsInstanceOfType(actual, GetType(MeasureGroup()), "Is not MeasureGroup Array")
        Assert.AreEqual(Of Integer)(1, actual.Count, "Count is not correct")
        Assert.AreEqual(Of Integer)(myMeasureGroup.GroupId, actual.First.GroupId, "Group ID is not correct")
    End Sub

    '''<summary>
    '''A test for AddMeasureGroup
    '''</summary>
    <TestMethod()> _
    Public Sub AddMeasureGroupTest()
        Dim status As Withings.Core.StatusResponseEnum = Withings.Core.StatusResponseEnum.Successfull
        Dim updateTime As DateTime = DateTime.Now
        Dim hasMore As Boolean = True
        Dim target As GetMeasuresResponse = New GetMeasuresResponse(status, updateTime, hasMore)
        Dim myMeasureGroup As New MeasureGroup()

        myMeasureGroup.AttributionStatus = AttributionStatusEnum.EnteredManually
        myMeasureGroup.Category = CategoryEnum.IsMeasure
        myMeasureGroup.GroupId = 1234
        myMeasureGroup.MeasureGroupDate = DateTime.Now

        target.AddMeasureGroup(myMeasureGroup)
        Assert.AreEqual(Of Integer)(1, target.ReadMeasureGroups.Count, "Count 1 is not correct")
        target.AddMeasureGroup(myMeasureGroup)
        Assert.AreEqual(Of Integer)(2, target.ReadMeasureGroups.Count, "Count 2 is not correct")
    End Sub

    '''<summary>
    '''A test for MeasureRequestResult Constructor
    '''</summary>
    <TestMethod()> _
    Public Sub MeasureRequestResultConstructorTest()
        Dim status As Withings.Core.StatusResponseEnum = Withings.Core.StatusResponseEnum.Successfull
        Dim updateTime As DateTime = DateTime.Now
        Dim hasMore As Boolean = True
        Dim target As GetMeasuresResponse = New GetMeasuresResponse(status, updateTime, hasMore)

        Assert.IsInstanceOfType(target, GetType(GetMeasuresResponse))
    End Sub
    End Class